<?php
date_default_timezone_set('prc');
header ( 'content-type:text/html; charset=utf-8' );
@$name = $_REQUEST ['name'];
session_start ();
if (! isset ( $_SESSION ['yazi'] )) {
	header ( 'Refresh:2;url=/deng1.php' );
	die ( '<h3>你还未登录，请先登录</h3>' );
}
require 'lib/eat.php';
$user = dbselectAll('select * from zhuo',array ( 'name' => $name ));

@$id=$_REQUEST['zhuoid'];
@$yixuan = $_REQUEST ['yixuanid'];
	
dbdelete('delete from zhuo_cai where dianid=:yixuanid',array('yixuanid'=>$yixuan));
?>

<!DOCTYPE html>
<html>
<head>
<title>点餐系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
	charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
         <script src="js/html5shiv.js"></script>
         <script src="js/respond.min.js"></script>
      <![endif]-->
</head>
<style>
	body{background:url(background/20151.jpg)}
	.input-group{
/ background-color: deeppink;/* IE9、标准浏览器、IE6和部分IE7内核的浏览器(如QQ浏览器)会读懂 */ */
 } 
.modal-content span{
  color: #FFFFFF;
}
.d{
  color: #FF00FF;

	.c {
	color: blue;
	}
	.a{
	color:blue;
	}
</style>
<body>
	<nav class="navbar navbar-default">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
					<span class="sr-only">切换</span> <span class="icon-bar"></span> <span
						class="icon-bar"></span> <span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="/th4.php">点餐系统</a>
			</div>
			<div class="collapse navbar-collapse"
				id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">订单管理 <span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="dinglie.php">订单列表</a></li>
							<li><a href="dingji.php">订单记录</a></li>
						</ul></li>
				</ul>
				<ul class="nav navbar-nav">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">菜品管理 <span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="jcp.php">添加菜品</a></li>
							<li><a href="cpl.php">菜品列表</a></li>
							<li class="divider"></li>
							<li><a href="jcx.php">添加菜品类型</a></li>
							<li><a href="cplie.php">菜品类型列表</a></li>
						</ul></li>
				</ul>
				<ul class="nav navbar-nav">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">餐桌管理 <span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="jiazhuo.php">添加餐桌</a></li>
							<li><a href="canzl.php">餐桌列表 </a></li>
						</ul></li>
				</ul>
				<ul class="nav navbar-nav">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">登录管理 <span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="#" data-toggle="modal" data-target="#aboutModal">关于点餐系统</a></li>
							<li><a href="xiugai.php">修改登录信息</a></li>
							<li><a href="#tui" data-toggle="modal">退出登录</a></li>
						</ul></li>
				</ul>
				<ul class="nav navbar-nav">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">个人中心<span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="yu.php">账户详情</a></li>
							<li class="divider"></li>
							<li><a href="yu.php?caoid=4">余额详情</a></li>
							<li><a href="yu.php?caoid=1">充值余额</a></li>
							<li class="divider"></li>
							<li><a href="yu.php?caoid=5">绑定银行卡</a></li>
							<li><a href="yu.php?caoid=3">修改支付密码</a></li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		<div class="modal fade" id="aboutModal" tabindex="-1">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal">
							<span>&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title">关于皇子大酒店点餐系统</h4>
					</div>
					<div class="modal-body">
						本皇子大酒店，精选优质渣料，<br> 选用上等地沟油，所有汤均用高级洗脚水熬制一天一夜而成。<br>
						各位顾客可放心点餐，我们还有优质的售后服务。<br> 我们保证在顾客吃后负责挖坑，免除顾客的后顾之忧。<br>
						最后，感谢各位顾客的光临，我们的酒店因你而生辉。

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-warning" data-dismiss="modal">确定</button>
					</div>
				</div>
			</div>
		</div>
		<div class="modal fade" id="tui" tabindex="-1">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal">
							<span>&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title">确定退出登录</h4>
					</div>
					<div class="modal-body">你确定要退出登录吗？</div>
					<div class="modal-footer">
						<a type="button" class="btn btn-default" href="tui.php">确定</a>
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>
		
	</nav>

	<div class="container">
		<div class="row">
			<div class="col-xs-3 col-sm-3 col-md-2 page-left">
				<div class="row">
					<form class="col-xs-12">
						<div class="form-group">
							<div class="input-group">
								<input class="form-control" placeholder="桌号">
								<div class="input-group-btn">
									<button type="submit" class="btn btn-default">
										<span class="glyphicon glyphicon-search"></span>
									</button>
								</div>
							</div>
							<input type="hidden" name="selectBoardId" value="">
						</div>
					</form>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<ul class="list-group">
					<?php for($i=0;$i<count($user);$i++){ ?>
					       					   <li class="list-group-item text-center"><a
								href="<?php echo "?zhuoid=".$user[$i]['id']?>"><span class="d"><?php echo $user[$i]['ming']?></span></a>
							</li>
 					<?php } ?>
 					</ul>
					</div>
				</div>
			</div>
			<?php
			@$id = $_REQUEST ['zhuoid'];
			
			$w = dbselect('select * from zhuo where id=:zhuoid',array ('zhuoid' => $id ));
// 			var_dump($w);
			?>
			<?php
			@$zhuoId=$_REQUEST['zhuoid'];
			@$caiId=$_REQUEST['caiid'];
			if(empty($zhuoId)&&!empty($caiId)){
				$message = "亲，请先选择餐桌，再点餐";
			}
			dbinsert('insert into zhuo_cai values(null,:zhuoid,:caiid)',array('zhuoid'=>$zhuoId,'caiid'=>$caiId));
			?>
			<div class="col-xs-9 col-sm-9 col-md-10">
				<?php if (! empty ( $message )) { ?>
					<div class="alert alert-danger text-center"><?php echo $message;?> 
					<a class="close" data-dismiss="alert">&times;</a>
					</div>
				<?php } ?>
				<div class="panel panel-primary">
					<div class="panel-heading">
						<div class="row" data-toggle="collapse" data-target="#xx">
							<div class="col-xs-2 col-sm-3" >
                				    <?php if(empty($id)){?>
        				                <h1 class="panel-title"
									style="margin-top: 5px;">
									<a data-toggle="collapse" href="#selectDishs"> <span
										class="glyphicon glyphicon-remove"></span> <span
										class="hidden-xs"> 没有选择餐桌 </span>
									</a>
								</h1>
        				                <?php }else { ?>
        				                	<h1 class="panel-title"
									style="margin-top: 5px;">
									<a data-toggle="collapse" href="#selectDishs"> <span
										class="glyphicon glyphicon-ok"></span> <span class="hidden-xs">
        				                	<?php echo $w['ming']?>-已选菜品 </span>
									</a>
								</h1>
        				               <?php }?>
        				     </div>
        				    <?php
	        				    $e=0;
								@$id = $_REQUEST ['zhuoid'];
								
								$a = dbselectAll('select * from zhuo_cai as room
								join zhuo
									on room.zhuoId=zhuo.id
								join cai
									on room.caiId=cai.id
								where zhuo.id=:zhuoid;',array ('zhuoid' => $id ));
	// 							var_dump($a);
							?>
							<?php
								@$leiid = $_REQUEST ['leiid'];
								
								if(empty($leiid)){
								$l = dbselectAll('select * from cai');
								}else {
									$l = dbselectAll('select * from cai where leiId=:leiid',array ('leiid' => $leiid));
								}
							?>
							<div align="right">
								<a href="" class="btn btn-warning" data-toggle="modal" data-target="#jiezhang">
									结账<span class="badge"><?php for($c=0;$c<count($a);$c++){
										$e+=$a[$c]['price'];
									}echo $e; ?>元</span>
								</a>
							</div>
						</div>
					</div>
					<div id="xx" class="in">
						<div class="modal-body" style="background-color: #B3EE3A">
						<div class="row">
							<?php for($c=0;$c<count($a);$c++){ ?>
							<div class="col-xs-3">
								<div class="thumbnail">
									<img src="<?php echo $a[$c]['src']?>" />
									<div class="caption"><?php echo $a[$c]['name']?>　<span
											class="c"><?php echo $a[$c]['price']?>元</span> 
											<a href="th4.php<?php echo '?yixuanid='.$a[$c]['dianid'].(!empty($id)?"&zhuoid=$id":'').(!empty($name)?"&name=$name":'').(!empty($leiid)?"&leiid=$leiid":'');?>">取消</a>
									</div>
								</div>
							</div>
							<div class="modal fade" id="<?php echo 'tuicai_'.$c;?>">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal">
												<span>&times;</span><span class="sr-only">Close</span>
											</button>
											<h4 class="modal-title">确定取消</h4>
										</div>
										<div class="modal-body">你确定要取消  <?php echo $a[$c]['name']?>  吗？</div>
										<div class="modal-footer">
											<a type="button" class="btn btn-default" href="san7.php<?php echo '?yixuanid='.$a[$c]['dianid'].(!empty($id)?"&zhuoid=$id":'');?>">确定</a>
											<button type="button" class="btn btn-default"
												data-dismiss="modal">取消</button>
										</div>
									</div>
								</div>
							</div>
							
							<?php }?>
						</div>
					</div>
					</div>
				</div>
				<div class="modal" id="jiezhang" tabindex="-1">
							<div class="modal-dialog">
								<div class="modal-content" style="background-color: #CD919E">
								<form action="ding.php?zhuoid=<?php echo $id?>" method="post">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal">
											<span>&times;</span><span class="sr-only">Close</span>
										</button>
										<h4 class="modal-title"><span>生成订单</span></h4>
									</div>
									<div class="modal-body">
								
									<h4><span>餐桌：</span></h4>  <div style="color:blue"><h4><?php echo $w['ming']; echo "\n";?></h4></div>
									<hr>
									<h4>已点菜品详细如下：</h4>
									<hr>
									<?php for($c=0;$c<count($a);$c++){?>
									<div class="text"><?php echo $a[$c]['name'];?>
									<span class="a" style="float:right"><span style="color:blue"><?php echo $a[$c]['price']?></span></span>
									<span style="float:right">单价：</span></div>
									<div style="margin-top:10px" class="caption text-right">数量：<span style="color:blue">x1</span></div>
									<hr>
									<?php }?>
									<div class="caption text-right">总共点餐：<span style="color:blue"><?php echo "$c";?></span>份</div>
									<input type="hidden" name="shuliang" value="<?php echo "$c";?>">
									<hr>
									<div class="caption text-right">结算总价：<span style="color:blue"><?php echo "$e";?></span>元</div>
									<hr>
									<div class="caption text-right">需付款：<span style="color:blue"><?php echo "$e";?></span>元</div>
									<input type="hidden" name="zongjia" value="<?php echo "$e";?>">
									<hr>
									<div class="caption text-right">订单生成时间：<?php $time=date('Y-m-d H:i:s'); echo "$time";?></div>
									<input type="hidden" name="shijian" value="<?php echo "$time";?>">
									</div>
									<div class="modal-footer">
										 <button type="submit" class="btn btn-default">提交订单</button>
										<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
									</div>
									</form>
								</div>
							</div>
						</div>
				
				<?php 
				@$name = $_REQUEST['name'];
				@$leiid = $_REQUEST ['leiid'];
				if(empty($leiid)){
					$l = dbselectAll('select * from cai');
				}else {
					$l = dbselectAll('select * from cai where leiId=:leiid',array ('leiid' => $leiid));
				}
				if (!empty($name)){
					$l = dbselectAll('select * from cai where name=:name',array ('name' => $name));
				}
					?>
				<div class="panel panel-primary">
					<div class="panel-heading">
					<div class="row">
						<div class="col-xs-6" class="title" data-toggle="collapse"
							data-target="#xx" data-parent="#pid">
							<h4>
								<span class="glyphicon glyphicon-th-list"> 可选菜品</span>
							</h4>
						</div>
						<div class="col-xs-4">
						<form action="">
							<div class="form-group" style="margin: 0;">
								<div class="input-group">
									<input type="text" name="name" value="" class="form-control" placeholder="搜索菜品">
									<input type="hidden" name="zhuoid" value="<?php echo (!empty($id)?"$id":'')?>">
									<span class="input-group-btn">
										<button class="btn btn-default" type="submit">
											<span class="glyphicon glyphicon-search"></span>
										</button>
									</span>
								</div>
							</div>
						</form>
						</div>
						<div class="col-xs-2">
							<form >
								<div class="form-group" style="margin: 0;">
									<div class="input-group-btn">
										<?php
										$d = dbselectAll('select * from lei');
										?>
											<select class="btn btn-default" name="leiid" style="font-size: 15.5px;">
											<option value="">类型</option>
			                           	 	<?php for($b=0;$b<count($d);$b++){?>
			                            		<option value="<?php echo $d[$b]['id']?>"><?php echo $d[$b]['lei'];?></option>
			                            	<?php }?>
			                            	</select>
										</div>
									<input type="hidden" name="zhuoid" value="<?php echo (!empty($id)?"$id":'')?>">
									<span class="input-group-btn">
												<button class="btn btn-default" type="submit">
													<span class="glyphicon glyphicon-search"></span>
												</button>
									</span>
								</div>
							</form>
						</div>
					</div>
					</div>
					<div class="modal-body" style="background-color: #B3EE3A">
						<div class="row">
									<?php for($b=0;$b<count($l);$b++){ ?>
									<div class="col-xs-3">
								<div class="thumbnail">
									<img alt="<?php echo $l[$b]['name']?>"
										src="<?php echo $l[$b]['src']?>" />
									<div class="caption text-center">
										<a href="th4.php<?php echo "?caiid=".$l[$b]['id'].(!empty($id)?"&zhuoid=$id":'').(!empty($name)?"&name=$name":'').(!empty($leiid)?"&leiid=$leiid":'');?>">
											<button
												class="btn btn-link btn-block"><?php echo $l[$b]['name']?>　<span
													class="c"><?php echo $l[$b]['price']?>元</span>
											</button> </a>
									</div>
								</div>
							</div>
									<?php } ?>
									</div>
					</div>

				</div>
			</div>
		</div>
	</div>
</body>
</html>